package com.panasonic.cn.cmsc;

import java.io.*;
import java.lang.*;
import java.util.*;
import java.math.*;
import java.sql.SQLException;
import com.fujitsu.fks.jaaf.core.*;

public class SQLMUSR05{
	private Hashtable paramsString     = new Hashtable();
	private Hashtable paramsBigDecimal = new Hashtable();
	private Hashtable paramsFree       = new Hashtable();
	private String lastSql_ = null;

	private String getString(String name){
		if(name==null) return "";
		String returnStr = (String)paramsString.get(name);
		if(returnStr==null) return "";
		return "'"+FrameworkCommon.stringReplaceSQuote(returnStr)+"'";
	}

	private String getBigDecimal(String name){
		if(name==null) return "";
		BigDecimal returnStr = (BigDecimal)paramsBigDecimal.get(name);
		if(returnStr==null) return "";
		return returnStr.toString();
	}

	private String getFree(String name){
		if(name==null) return "";
		String returnStr = (String)paramsFree.get(name);
		if(returnStr==null) return "";
		return returnStr;
	}

	public String getLastSql(){
		return lastSql_;
	}

	public SelectResultRset SELECT_USR01(FrameworkDbCommon db) throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append("	SELECT ");
		sql.append("NVL( USER_ID,'') AS USER_ID,");
		sql.append("NVL( USER_NAME,'') AS USER_NAME,");
		sql.append("NVL( PASSWORD,'') AS PASSWORD,");
		sql.append("NVL( CTRL_DVSN_CD,'') AS CTRL_DVSN_CD,");
		sql.append("NVL( AUTH_LEVEL,'') AS AUTH_LEVEL,");
		sql.append("NVL( BSNS_TYP,'') AS BSNS_TYP,");
		sql.append("NVL( MAIL_ADDRESS,'') AS MAIL_ADDRESS,");
		sql.append("NVL( MAIL_SIZE,'') AS MAIL_SIZE,");
		sql.append("NVL( L_DSP_NO,'') AS L_DSP_NO,");
		sql.append("NVL( MENU_TYP,'') AS MENU_TYP,");
		sql.append("NVL( PSW_TEST,'') AS PSW_TEST,");
		sql.append("NVL( USER_AB_ID,'') AS USER_AB_ID,");
		sql.append("TO_CHAR(NVL( RGS_DTTM,''),'YYYYMMDDHH24MISS') AS RGS_DTTM,");
		sql.append("NVL( RGS_CHRG_CD,'') AS RGS_CHRG_CD,");
		sql.append("NVL( RGS_PGID,'') AS RGS_PGID,");
		sql.append("TO_CHAR(NVL( UPD_DTTM,''),'YYYYMMDDHH24MISS') AS UPD_DTTM,");
		sql.append("NVL( UPD_CHRG_CD,'') AS UPD_CHRG_CD,");
		sql.append("NVL( UPD_PGID,'') AS UPD_PGID ");
		sql.append("FROM USR ");
		sql.append("WHERE USER_ID "+((getString("USER_ID").equals(""))?" is null ":"=")+getString("USER_ID")+" ");
		db.setSql(sql.toString());
		lastSql_ =sql.toString();
		SelectResultRset srr = db.executeQuery();
		paramsString     = new Hashtable();
		paramsBigDecimal = new Hashtable();
		paramsFree       = new Hashtable();

		return srr;
	}


	public void setUSER_ID(String value){
		if(value==null) {
			paramsString.remove("USER_ID");
			return;
		}
		paramsString.put("USER_ID",value);
	}


}
